import com.gientech.spring.model.Coffee;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author liubin
 */
public class SpringBeanApplication {

    public static void main(String[] args) {
        /**
         * ClassPathXmlApplicationContext 是spring衆多配置文件中的一種加載方式，表示從classpath下加載配置文件
         * 其他常見的配置文件加載方式還有：
         *  FileSystemXmlApplicationContext
         *  AnnotationConfigReactiveWebApplicationContext
         *  ReactiveWebServerApplicationContext
         *  StaticApplicationContext
         *  ResourceAdapterApplicationContext
         *  都是繼承至AbstractApplicationContext
         */
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring-beans.xml");
        // 通過類型獲取，或通過xml文件中配置的name獲取：getBean("coffee");
        Coffee coffee = ctx.getBean(Coffee.class);
        System.out.println("Coffee bean = " + coffee);
    }
}
